﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class Prefs {

    public static int CurrentLevel
    {
        get { return PlayerPrefs.GetInt("current_level"); }
        set { PlayerPrefs.SetInt("current_level", value); }
    }

    public static int UnlockedLevel
    {
        get { return PlayerPrefs.GetInt("unlocked_level"); }
        set { PlayerPrefs.SetInt("unlocked_level", value); }
    }

    public static List<int> GetPanWordIndexes(int level)
    {
        string data = PlayerPrefs.GetString("pan_word_indexes_v2_" + level);
        return CUtils.BuildListFromString<int>(data);
    }

    public static void SetPanWordIndexes(int level, int[] indexes)
    {
        string data = CUtils.BuildStringFromCollection(indexes);
        PlayerPrefs.SetString("pan_word_indexes_v2_" + level, data);
    }

    public static bool IsLastLevel()
    {
        return CurrentLevel == UnlockedLevel;
    }

    public static void SetExtraWords(int level, string[] extraWords)
    {
        CryptoPlayerPrefsX.SetStringArray("extra_words_" + level, extraWords);
    }

    public static string[] GetExtraWords(int level)
    {
        return CryptoPlayerPrefsX.GetStringArray("extra_words_" + level);
    }

    public static int ExtraProgress
    {
        get { return CPlayerPrefs.GetInt("extra_progress", 0); }
        set { CPlayerPrefs.SetInt("extra_progress", value); }
    }

    public static int TotalExtraAdded
    {
        get { return CPlayerPrefs.GetInt("total_extra_added", 0); }
        set { CPlayerPrefs.SetInt("total_extra_added", value); }
    }

    public static string[] LevelProgress
    {
        get { return CryptoPlayerPrefsX.GetStringArray("level_progress"); }
        set { CryptoPlayerPrefsX.SetStringArray("level_progress", value); }
    }

    public static void AddToNumHint(int level)
    {
        int numHint = GetNumHint(level);
        PlayerPrefs.SetInt("numhint_used_" + level, numHint + 1);
    }

    public static int GetNumHint(int level)
    {
        return PlayerPrefs.GetInt("numhint_used_" + level);
    }
}
